<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box1 {
            width: 300px;
            height: 300px;
            background-color: blue;
        }

        #box2 {
            width: 200px;
            height: 200px;
            background-color: blueviolet;
        }
    </style>
</head>

<body>
    <div id="box1">
        box1-最外层
        <div id="box2">
            box2-中间层
        </div>
    </div>

    <script>
        box1.onclick = function () {
            console.log("父亲的事件");
        }
        box2.onclick = function (event) {
            event.stopPropagation();
            
            console.log("儿子的事件");
        }

        // box1.addEventListener('click', function () {
        //     console.log("父亲的事件");
        // }, true)
        // box2.addEventListener('click', function () {
        //     console.log("儿子的事件");
        // }, true)
    </script>
</body>

</html>